package com.kuang.springclound.service;

import com.kuang.springclound.pojo.SystemDept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

//降级
@Component//丢到Spring容器中
public class DeptClientServiceFallBackFactory implements FallbackFactory {

    @Override
    public DeptClientService create(Throwable throwable) {
        return new DeptClientService() {
            @Override
            public SystemDept queryById(Long id) {
                return new SystemDept()
                        .setDept_id(id)
                        .setDept_name("id->" + id + "没有对应的信息，客户端提供了降级服务的信息，这个服务现在已经被关闭了")
                        .setDb_source("没有数据~");
            }

            @Override
            public List<SystemDept> queryAll() {
                return null;
            }

            @Override
            public boolean addDept(SystemDept systemDept) {
                return false;
            }
        };
    }

}
